﻿using BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UI;

namespace WindowsFormsApp1
{
    public partial class LoginForm : Form
    {
        private UserController userController;
        public LoginForm()
        {
            userController = new UserController();
            InitializeComponent();
        }

        // 退出
        private void exit_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        // 登录
        private void login_Click(object sender, EventArgs e)
        {
            // 登录成功开启主窗口
            // 验证登录
            var flag = userController.Login(this.userNameTextBox.Text, this.passwordTextBox.Text);
            if (flag)
            {
                // 登录成功开启主窗口
                MessageBox.Show($"登录成功");
                var main = new MainForm();
                main.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show($"用户名或者密码错误");
            }
        }
    }
}
